7.3 EMP_inject

Unlike traditional closed analysis systems, EMP employs an 'open encapsulation' design philosophy that preserves the advantages of data containerization while enabling users to import external analysis results into the framework. This approach allows seamless integration and joint analysis of externally generated data with native EasyMultiProfiler analytical outputs within a unified environment.

🏷️Example: Users can import the results from the external vegan package to calculate diversity into the EMPT object.

Step 1: Extract the species data of the microorganisms.

tax_se <- MAE |> 
  EMP_assay_extract('taxonomy')

assay_data <- tax_se |> 
  EMP_assay_extract(action = 'get')

Step 2: The Shannon diversity index was calculated using the vegan package and named new_shannon.

assay_data <- assay_data |> tibble::column_to_rownames('primary')
shannon_index <- vegan::diversity(assay_data,index = 'shannon') 
new_result <- tibble::tibble(primary=names(shannon_index),new_shannon=shannon_index)
new_result

Note:
The name in the new result must be unique and not duplicate any existing names in the data results; otherwise, the function EMP_filter will not work correctly. For example, in this case, you need to rename the Shannon index from an external result to new_shannon to avoid conflicts with the result name from EMP_alpha_analysis.

Step 3: Inject the result into the EMPT in the pipe.

 obj |>
   EMP_inject(value = new_result,value_name = 'new_alpha',
              affect_when_sample_changed=0,
              affect_when_feature_changed=1,
              attribute='primary',
              attribute2='normal',source='user_import') |>
   EMP_filter(sample_condition  = new_shannon >2)

Copyright © 382983280@qq.com 2024 all right reserved,powered by Gitbook更新时间: 2025-08-15 02:13:34

results matching ""

    No results matching ""